package com.ctshk.sapp.goods.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.goods.dto.ShoppingSpecialDetailedDTO;
import com.ctshk.rpc.goods.dto.ShoppingSpecialPageDTO;
import com.ctshk.rpc.goods.req.ShoppingSpecialPageReq;
import com.ctshk.rpc.goods.req.ShoppingSpecialReq;
import com.ctshk.rpc.goods.service.IShoppingSpecialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 商城专题 前端控制器
 * </p>
 *
 * @author 姜斌文
 * @since 2021-04-30
 */
@Api(value="商城专题", tags="商城专题")
@RestController
@RequestMapping("/shopping/special")
public class ShoppingSpecialController extends BaseController {

    @DubboReference
    private IShoppingSpecialService shoppingSpecialService;

    @ApiOperation(value = "新增商城专题", notes = "新增商城专题")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.ADD, operTitle = "新增商城专题", operDesc = "新增商城专题")
    @PostMapping("/addShoppingSpecial")
    public Result addShoppingSpecial(@RequestBody @Valid ShoppingSpecialReq obj) {
        shoppingSpecialService.addShoppingSpecial(obj, getCurrentUser(getRequest()));
        return Result.success();
    }

    @ApiOperation(value = "编辑商城专题/编辑是否显示状态", notes = "编辑商城专题/编辑是否显示状态")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "编辑商城专题/编辑是否显示状态", operDesc = "编辑商城专题/编辑是否显示状态")
    @PostMapping("/updateShoppingSpecial")
    public Result updateShoppingSpecial(@RequestBody @Valid ShoppingSpecialReq obj) {
        shoppingSpecialService.updateShoppingSpecial(obj,getCurrentUser(getRequest()));
        return Result.success();
    }

    @ApiOperation(value = "分页查询商城专题管理", notes = "分页查询商城专题管理")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "分页查询商城专题管理", operDesc = "分页查询商城专题管理")
    @PostMapping("/findPageList")
    public Result<PageResponse<ShoppingSpecialPageDTO>> queryList(@RequestBody ShoppingSpecialPageReq pageReq) {
        PageResponse<ShoppingSpecialPageDTO> response = shoppingSpecialService.findShoppingSpecialPageList(pageReq,getCurrentUser(getRequest()));
        return Result.success(response);
    }

    @ApiOperation(value = "查询商城专题明细", notes = "查询商城专题明细")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查询商城专题明细", operDesc = "查询商城专题明细")
    @PostMapping("/findShoppingSpecialDetailed")
    public Result<ShoppingSpecialDetailedDTO> findShoppingSpecialDetailed(@RequestBody ShoppingSpecialPageReq req) {
        ShoppingSpecialDetailedDTO response = shoppingSpecialService.findShoppingSpecialDetailed(req,getCurrentUser(getRequest()));
        return Result.success(response);
    }
}
